package com.greenant.store.bean;

import java.util.List;

import android.util.Log;

import com.avos.avoscloud.AVACL;
import com.avos.avoscloud.AVClassName;
import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVQuery;
import com.avos.avoscloud.AVRole;
import com.avos.avoscloud.AVUser;
import com.avos.avoscloud.FindCallback;

@AVClassName(AntAVObject.CLASS_SERVERSECTION)
public class ServerSection extends AntAVObject
{

    public static final String ATTR_USRID = "usrId";
    public static final String ATTR_SECTIONNUM = "sectionNum";//对应ATTR_AREA来区分
    
    public static final String ATTR_UPTOWN = "uptown";// 淮祥园
    public static final String ATTR_STREET = "street";// 姚江东路
    public static final String ATTR_AREA = "area";// 北辰区
    public static final String ATTR_CITY = "city";// 天津
    public static final String ATTR_PROVINCE = "province";// 天津
    public static final String ATTR_PICKUPSTATION = "pickupStation";// 自提点
    public static final String ATTR_SHOWCARTSTOREID = "showCartStoreId";

    private AVRole customRole;

    public ServerSection()
    {
        super();
        setAccessCtrl();
    }

    public ServerSection(String str)
    {
        super(str);
        setAccessCtrl();
    }

    public int getSectionnum()
    {
    	return this.getInt(ATTR_SECTIONNUM);
    }

    public void setSectionnum(int sectionnum)
    {
        this.put(ATTR_SECTIONNUM, sectionnum);
    }
    
    public String getPickupStation()
    {
        return this.getString(ATTR_PICKUPSTATION);
    }

    public void setPickupStation(String uptown)
    {
        this.put(ATTR_PICKUPSTATION, uptown);
    }
    public String getUptown()
    {
        return this.getString(ATTR_UPTOWN);
    }

    public void setUptown(String uptown)
    {
        this.put(ATTR_UPTOWN, uptown);
    }
    
    public String getShowCartStoreId()
    {
        return this.getString(ATTR_SHOWCARTSTOREID);
    }

    public void setShowCartStoreId(String showCartStoreId)
    {
        this.put(ATTR_SHOWCARTSTOREID, showCartStoreId);
    }
    
    public String getStreet()
    {
        return this.getString(ATTR_STREET);
    }

    public void setStreet(String street)
    {
        this.put(ATTR_STREET, street);
    }
    
    public String getArea()
    {
        return this.getString(ATTR_AREA);
    }

    public void setArea(String area)
    {
        this.put(ATTR_AREA, area);
    }
    
    public String getCity()
    {
        return this.getString(ATTR_CITY);
    }

    public void setCity(String city)
    {
        this.put(ATTR_CITY, city);
    }
    
    public String getProvince()
    {
        return this.getString(ATTR_PROVINCE);
    }

    public void setProvince(String province)
    {
        this.put(ATTR_PROVINCE, province);
    }
    
 

    public ServerSection getInstance()
    {
        return this;
    }

    public String getUserId()
    {
        return this.getString(ATTR_USRID);
    }

    private void setUserId(String userId)
    {
        this.put(ATTR_USRID, userId);
    }

    private int setAccessCtrl()
    {

        acl = new AVACL();
        acl.setPublicReadAccess(true);//�˴����õ��������˵Ŀɶ�Ȩ��
//        acl.setReadAccess(AVUser.getCurrentUser(), true);
//        acl.setWriteAccess(AVUser.getCurrentUser(), true);// �������������ļ������ߵ�дȨ��
//        this.setACL(acl);
//        this.setUserId(AVUser.getCurrentUser().getObjectId());
//        AVQuery<AVRole> query = new AVQuery<AVRole>("_Role");
//        query.whereEqualTo("name", "custom");
//        query.findInBackground(new FindCallback<AVRole>()
//        {
//            @Override
//            public void done(List<AVRole> avObjects, AVException e)
//            {
//                if (e == null)
//                {
//                    customRole = (AVRole) avObjects.get(0);
//                    acl.setRoleReadAccess(customRole, true);
//                    getInstance().setACL(acl);
//
//                } else
//                {
//                    Log.d("ʧ��", "��ѯ����: " + e.getMessage());
//                }
//            }
//
//        });
        return 0;
    }

}
